#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <unistd.h>
#include <string.h>

#include "linkqueue.h"

int main(int argc, char const *argv[])
{
    int a[12] = {2, 6, 7, 3, 2, 6, 5, 8, 9, 11, 3, 4};

    linkqueue *q = init_queue();
    int maxLen = 0;

    for(int i=0; i<12; i++)
    {
        // 1. 判定即将要入队的节点是否存在
        while(!is_empty(q) && find(q, a[i]))
        {
            list p;
            out_queue(q, &p); // 队列会变短
            free(p);
            maxLen = maxLen>q->size? maxLen : q->size;
        }
        en_queue(q, new_node(a[i]));
        maxLen = maxLen>q->size? maxLen : q->size;
    }
    printf("maxLen: %d\n", maxLen);

    return 0;
}
